<!-- PAGE CONTENT WRAPPER -->
<div class="page-content-wrap">
  <div class="row">
    <div class="col-md-12">

      <!-- START BASIC TABLE SAMPLE -->
      <div class="panel panel-default">
        <div class="panel-heading">
            <div class="row">
                <div class="col-md-12">
                    <h4 class="pull-left"><span class="fa fa-file-o"></span> <%= t('camaleon_cms.admin.users.list_users') %></h4>
                    <%= link_to raw("<i class='fa fa-plus'></i> #{t('camaleon_cms.admin.users.add_user')}"), {action: :new}, class: "btn btn-primary pull-right cama_ajax_request" %>
                </div>
            </div>
        </div>
        <div class="panel-body">

          <table class="table table-responsive table-hover table-striped">
            <thead>
            <tr>
              <th><%= t('camaleon_cms.admin.table.id') %></th>
              <th><%= t('camaleon_cms.admin.table.username') %></th>
              <th><%= t('camaleon_cms.admin.table.email') %></th>
              <th><%= t('camaleon_cms.admin.table.role') %></th>
              <th><%= t('camaleon_cms.admin.table.last_login') %></th>
              <th><%= t('camaleon_cms.admin.table.actions') %></th>
            </tr>
            </thead>
            <tbody>
            <% @users.decorate.each do |f| %>
                <tr>
                  <td><%= f.id %></td>
                  <td><%= f.username %></td>
                  <td><%= f.email %></td>
                  <td><%= f.the_role %></td>
                  <td><%= l(f.last_login_at, format: :long) if f.last_login_at.present? %></td>
                  <td>
                    <%= link_to raw('<i class="fa fa-pencil"></i>'), {action: :edit, id: f.id }, class: "btn btn-default btn-xs cama_ajax_request", title: "#{t('camaleon_cms.admin.button.edit')}" %>
                    <% if cama_current_user.id == f.id %>
                        <%= link_to 'javascript:;', class: 'btn btn-danger btn-xs cama_ajax_request', disabled: true,
                                title: t('camaleon_cms.admin.users.message.user_can_not_delete_own_account', default: 'User can not delete own account') do %>
                            <i class="fa fa-times"></i>
                        <% end %>
                    <% else %>
                        <%= link_to raw('<i class="fa fa-times"></i>'), { action: :destroy, id: f.id },
                                method: :delete, data: { confirm: t('camaleon_cms.admin.message.delete_item') }, class: "btn btn-danger btn-xs cama_ajax_request", title: "#{t('camaleon_cms.admin.button.delete')}" %>
                    <% end %>
                    <%= link_to raw('<i class="fa fa-retweet"></i>'), {action: :impersonate, id: f.id }, class: "btn btn-default btn-xs cama_ajax_request", title: "#{cama_t('camaleon_cms.admin.users.impersonate')}" if can? :impersonate, f %>
                  </td>
                </tr>
            <% end %>

            </tbody>
          </table>
          <%= content_tag("div", raw(t('camaleon_cms.admin.message.data_found_list')), class: "alert alert-warning") if @users.empty? %>
            <%= raw cama_do_pagination(@users) %>
        </div>
      </div>
      <!-- END BASIC TABLE SAMPLE -->
    </div>
  </div>

</div>
